package com.atguigu.gmall.secKill.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.activity.SeckillGoods;
import com.atguigu.gmall.secKill.service.SecKillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author ZengMing
 * @Date 2021/7/14 19:38
 * @Description:秒杀商品controller类
 */
@RequestMapping(value = "/secKill/goods")
@RestController
public class SecKillGoodsController {

    @Autowired
    private SecKillService secKillService;

    /**
     * 秒杀商品列表
     * @param time
     * @return
     */
    @GetMapping(value = "/list/{time}")
    public Result getSeckillGoods(@PathVariable(value = "time") String time){
        List<SeckillGoods> seckillGoodsList = secKillService.getSeckillGoods(time);
        return Result.ok(seckillGoodsList);
    }

    /**
     * 秒杀商品详情
     * @param time
     * @return
     */
    @GetMapping(value = "/getSeckillGood/{time}/{id}")
    public Result getSeckillGood(@PathVariable(value = "time") String time,
                                 @PathVariable(value = "id") String id){
        SeckillGoods seckillGood = secKillService.getSeckillGood(time, id);
        return Result.ok(seckillGood);
    }
}
